RNAseq<-read.csv("RNAseq.CSV")
RNAseq <- as.data.frame(RNAseq)
rownames(RNAseq) = RNAseq[,1]
RNAseq<-RNAseq[,-1]
# 安装 Bioconductor 包管理器
install.packages("BiocManager")
# 使用 BiocManager 安装 DESeq2
BiocManager::install("DESeq2")
library(DESeq2)
colData<-a1.1
colData$分组 <- ifelse(colData$年龄 < 65, "midlife", "old")
colData <- colData[match(colnames(RNAseq), rownames(colData)), ]
all(colnames(RNAseq) == rownames(colData)) 
RNAseq <- round(RNAseq)
colData$分组 <- as.factor(colData$分组)
dds <- DESeqDataSetFromMatrix(countData = RNAseq, colData = colData, design =~ 分组)
dds <- DESeq(dds)
res <- results(dds)
head(res)
library(ggplot2)
# 转化为data.frame
res_df <- as.data.frame(res)
ggplot(res_df, aes(x = log2FoldChange, y = -log10(padj))) +
  geom_point(aes(color = padj < 0.05), alpha = 0.6) +
  scale_color_manual(values = c("gray", "red")) +
  theme_minimal() +
  labs(x = "log2 Fold Change", y = "-log10 Adjusted P-value", title = "Volcano Plot")
